#!/usr/bin/env python
#coding:utf-8
import urllib2
from sgmllib import SGMLParser

class URLLister(SGMLParser):
    def reset(self):
        SGMLParser.reset(self)
        self.urls = []

    def start_a(self, attrs):
        href = [v for k, v in attrs if k=='href']
        if href:
            if href[0].count('http://wyattwanglife.appspot.com') == 1:
                self.urls.extend(href)

links = ['http://www.google.com/',
         'http://www.baidu.com',
         'http://www.yahoo.com/',
         'http://www.bing.com',]

for eachlink in links:
    f = urllib2.urlopen(eachlink)
    if f.code == 200:
        p = URLLister()
        p.feed(f.read())
        f.close()
        if len(p.urls) >= 1:
            print 'The link from %s is OK!' % eachlink
        else:
            print 'The link from %s is Error!' % eachlink
